
<script type="text/javascript">
function checkPost(){
	if($("#postContent").val().length <5){
		alert("回复不得少于5个字");
		return false;
	}
}

</script>
<script type="text/javascript">
    <!--
    function setFocus(){
        document.replyform.postContent.focus();
        document.replyform.postContent.innerHTML='';
    }
    -->
</script>

<!-- Start of first page -->
<div data-role="page">
		<div data-role="header" data-theme="b">
			<?php if(Yii::app()->user->isGuest):?>
			<h1>iLook - 新闻</h1>
			<?php else:?>
			<h1>欢迎 :<?php echo Yii::app()->user->name?></h1>
			<?php endif?>
			<?php echo CHtml::link("$news->title",array("news/list","id"=>"$news->id"),array("data-role"=>"button","data-icon"=>"back"))?>
			<a data-role="button" data-icon="arrow-d" href="#" onclick="javascript:setFocus()">评论</a>
		</div>
		<!-- /header -->
		<div class="content-primary">
		<?php $this->renderPartial("//site/toolbar")?>
		<div class="ui-body ui-body-c tie-top-ads" style="text-align: center;">
				广告区
		</div>

	<?php if(Utils::checkMobile()==0):?>
	<div>
</div>
	<?php endif?>	
			<?php $thisPage = $pages->currentPage;?>
			<?php $n= $thisPage*20;?>
			<?php foreach($posts as $post):?>
			<?php if($post->flag !='inactive'):?>
				<?php if($n==1):?>
			<br/>
			<div class="ui-body ui-body-b tie-body">
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer">评论区</div>
					<div class="ui-block-b tie-footer" style ="text-align:right;">
					<?php echo $topic->comments;?>条精彩评论	
					</div>
				</div><!-- /grid-a -->
			</div><!-- /themed container -->
				<?php endif?>
			<div class="ui-body ui-body-d tie-body">
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer"><?php echo $n!=0? $n."楼":$news->title?></div>
					<div class="ui-block-b tie-footer" style ="text-align:right;">
						<?php if($n!=0):?><a style="text-decoration: none;" rel='external' href="<?php echo Yii::app()->createUrl('news/reply', array('id'=>$topic->id,'title'=>$n."楼：",'post_id'=>$post->id)); ?> ">	引用</a><?php endif?>
					</div>
				</div><!-- /grid-a -->
					<?php  if($n==0):?>	
				<div class="tie-title">
					<strong><?php echo $post->title?></strong>
				</div>
					<?php endif?>
					<?php if(Utils::checkMobile()==0):?>
				<div class='tie-body-content'>
					<?php echo $content=nl2br($post->content);?>
				</div>
					<?php else:?>
				<div class='tie-body-mobile'>
					<?php echo $content=nl2br($post->content);?>
				</div>
					<?php endif?>
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer">作者:
						<?php if(!empty($post->member_id)):?>
						<a style="text-decoration: none;color:#0B3861" rel='external' href="<?php echo Yii::app()->createUrl('news/user', array('id'=>$post->member_id));?> "><?php echo $post->author;?></a>
						<?php else:?>
						<?php echo
						substr($post->author, 0, strripos($post->author,'.') ).".***"?>
						<?php endif?>
					</div>
					<div class="ui-block-b tie-footer" style ="text-align:right"><?php echo mb_substr($post->created,0,16,"UTF-8");?></div>
				</div><!-- /grid-a -->			
			</div><!-- /themed container -->
			<?php endif?>
			<?php $n++;?>
			<?php endforeach?>

			<?php if($pages->pageCount>1):?>
					<div data-role="controlgroup" data-type="horizontal" style="margin-left:10px;">
					<?php
					$currentPage = $pages->currentPage+1;
					echo CHtml::link("首页",array("","id"=>$topic->id,"page"=>1), array("data-role"=>"button",'rel'=>'external'));
					for($i=$currentPage-2;$i<=$currentPage+1;$i++){
						if($i<1 || $i>$pages->pageCount){
							continue;
						}
						if($i==$currentPage){
							echo CHtml::link($i,array("","id"=>$topic->id,"page"=>$i), array("data-role"=>"button","data-theme"=>'b','rel'=>'external'));
						}else{
							echo CHtml::link($i,array("","id"=>$topic->id,"page"=>$i), array("data-role"=>"button",'rel'=>'external'));
						}
					}
					echo CHtml::link("末页",array("","id"=>$topic->id,"page"=>$pages->pageCount), array("data-role"=>"button",'rel'=>'external'));
					?>
					</div>
			<?php endif?>
		</div>
		
		<div style="margin:5px 5px 5px 5px;">
		<?php echo CHtml::form('','post',array("onsubmit"=>"return checkPost();","data-ajax"=>"false","name"=>"replyform")); ?>
			<input type="hidden" name="NewsPost[topic_id]"
				value="<?php echo $topic->id;?>" />
			<textarea style='width: 95%; height: 100px;' name="NewsPost[content]"
				id='postContent' onclick="this.innerHTML=''"
				>评论。。</textarea>
			<input type='submit' data-theme='b' value='评论' data-inline='true'/>
		<?php echo CHtml::endForm(); ?>
		</div>

		<!--/content-primary -->

		<?php $this->renderPartial("//site/footer")?>
		<!-- /footer -->
</div>
<!-- /page -->

